home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Skunkware 98
/
Skunkware 98.iso
/
src
/
mail
/
pine3.96.tar.gz
/
pine3.96.tar
/
pine3.96
/
pine
/
osdep
/
print.win
< prev
next >
Wrap
Text File
|
1995-07-14
|
4KB
|
156 lines
#line 2 "osdep/print.win"
/*======================================================================
print routines
Functions having to do with printing on paper and forking of spoolers
In general one calls open_printer() to start printing. One of
the little print functions to send a line or string, and then
call print_end() when complete. This takes care of forking off a spooler
and piping the stuff down it. No handles or anything here because there's
only one printer open at a time.
====*/
/*----------------------------------------------------------------------
Open the printer
Args: desc --Description of item to print. Should have on tailing blank.
This does most of the work of popen so we can save the standard output of the
command we execute and send it back to the user.
----*/
int
open_printer(desc)
char *desc;
{
unsigned short status;
if (status = mswin_print_ready (0, desc)) {
q_status_message1(SM_ORDER | SM_DING, 3, 4,
"Error starting print job: %s",
mswin_print_error(status));
return(-1);
}
q_status_message(SM_ORDER, 0, 9, "Printing to windows printer...");
display_message('x');
/* init print control structure */
ps_global->print = (PRINT_S *)fs_get(sizeof(PRINT_S));
memset(ps_global->print, 0, sizeof(PRINT_S));
ps_global->print->err = 0;
return(0);
}
/*----------------------------------------------------------------------
Close printer
If we're piping to a spooler close down the pipe and wait for the process
to finish. If we're sending to an attached printer send the escape sequence.
Also let the user know the result of the print
----*/
void
close_printer()
{
mswin_print_done();
fs_give((void **)&ps_global->print);
q_status_message(SM_ASYNC, 0, 3, "Print command completed");
display_message('x');
}
/*----------------------------------------------------------------------
Print a single character
Args: c -- char to print
Returns: 1 on success, 0 on ps_global->print->err
----*/
int
print_char(c)
int c;
{
if(!ps_global->print->err
&& (ps_global->print->err = mswin_print_char (c)))
q_status_message1(SM_ORDER, 0, 9, "Print cancelled: %s",
mswin_print_error((unsigned short)ps_global->print->err));
return(!ps_global->print->err);
}
/*----------------------------------------------------------------------
Send a line of text to the printer
Args: line -- Text to print
----*/
void
print_text(line)
char *line;
{
if(!ps_global->print->err
&& (ps_global->print->err = mswin_print_text(line)))
q_status_message1(SM_ORDER, 0, 9, "Print cancelled: %s",
mswin_print_error((unsigned short)ps_global->print->err));
}
/*----------------------------------------------------------------------
printf style formatting with one arg for printer
Args: line -- The printf control string
a1 -- The 1st argument for printf
----*/
void
print_text1(line, a1)
char *line, *a1;
{
sprintf(tmp_20k_buf, line, a1);
print_text(tmp_20k_buf);
}
/*----------------------------------------------------------------------
printf style formatting with one arg for printer
Args: line -- The printf control string
a1 -- The 1st argument for printf
a2 -- The 2nd argument for printf
----*/
void
print_text2(line, a1, a2)
char *line, *a1, *a2;
{
sprintf(tmp_20k_buf, line, a1, a2);
print_text(tmp_20k_buf);
}
/*----------------------------------------------------------------------
printf style formatting with one arg for printer
Args: line -- The printf control string
a1 -- The 1st argument for printf
a2 -- The 2nd argument for printf
a3 -- The 3rd argument for printf
----*/
void
print_text3(line, a1, a2, a3)
char *line, *a1, *a2, *a3;
{
sprintf(tmp_20k_buf, line, a1, a2, a3);
print_text(tmp_20k_buf);
}